﻿<UserControl x:Class="Hopscotch.Presentation.DiagnosticsModule.Views.SystemDiagnosticsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:prism="http://www.codeplex.com/prism"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             xmlns:lvms="clr-namespace:Hopscotch.Presentation.DiagnosticsModule.ViewModels"
             mc:Ignorable="d"
             d:DataContext="{d:DesignInstance Type=lvms:SystemDiagnosticsViewModel}"
             d:DesignHeight="300" d:DesignWidth="300">

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <ei:CallMethodAction TargetObject="{Binding}" MethodName="StartMemoryTracking" />
            <!--<prism:InvokeCommandAction Command="{Binding Path=StartMemoryTrackingCommand}" />-->
        </i:EventTrigger>
        <i:EventTrigger EventName="Unloaded">
            <ei:CallMethodAction TargetObject="{Binding}" MethodName="StopMemoryTracking" />
        </i:EventTrigger>
    </i:Interaction.Triggers>

    <DockPanel LastChildFill="True">

        <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" >
            <Button Command="{Binding GcCollectCommand}">Collect Garbage</Button>
        </StackPanel>
        
        <Grid DockPanel.Dock="Top">

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />

            </Grid.RowDefinitions>

            <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Text="UI Thread Id: " />
            <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Text="{Binding Model.ThreadId}"/>

            <TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Text="Physical Memory Usage: " />
            <TextBlock Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Text="{Binding Model.PhysicalMemoryUsage}"/>

            <TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Text="Peak Physical Memory Usage: " />
            <TextBlock Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Text="{Binding Model.PeakWorkingSet}"/>

            <TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Text="Peak Paged Memory Usage: " />
            <TextBlock Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" Text="{Binding Model.PeakPagedMemorySize}"/>

            <TextBlock Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" Text="Peak Virtual Memory Usage: " />
            <TextBlock Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" Text="{Binding Model.PeakVirtualMemorySize}"/>

            <TextBlock Grid.Row="0" Grid.Column="2" VerticalAlignment="Center" Text="User Processor Time: " />
            <TextBlock Grid.Row="0" Grid.Column="3" VerticalAlignment="Center" Text="{Binding Model.UserProcessorTime}"/>

            <TextBlock Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" Text="Total Processor Time: " />
            <TextBlock Grid.Row="1" Grid.Column="3" VerticalAlignment="Center" Text="{Binding Model.TotalProcessorTime}"/>

        </Grid>
        
    </DockPanel>
</UserControl>
